package com.test03_类与对象;

/**
 * 匿名对象
 */
public class YootkDemo_04 {

    public static void main(String[] args) {
        for (int x = 0; x < 100; x++) {
            sale(new Food("西红柿烤烧饼", 7.9));
        }
    }

    // 卖出实物
    public static void sale(Food temp) {
        System.out.println("【卖出商品】" + temp.getInfo());
    }
}

/**
 * 食物类
 */
class Food {
    private String name;
    private double price;

    public Food(String n, double p) {
        name = n;
        price = p;
    }

    public String getInfo() {
        return "名称：" + name + "、价格：" + price;
    }
}
